<?php 
include '../data/data.php';
include '../data/ip.php';
$user=$_POST['username'];  //账号
$pass=$_POST['password'];  //密码
$password=md5($_POST['password']);  //密码
$remember=$_POST['remember']; //返回地址
$type=$_POST['type']; //操作方式
#__________________________________________
  if($user=='' & $pass=='' & $type==''){
    $returndata = array("msg"=>false,"log"=>"滚犊子","fwd"=>"");
    exit(json_encode($returndata));
  }
if($remember=='null'){
$rememb='/user/user.html';
}else{
$rememb=$remember;
}
if($type=='login'){
$result= mysql_query("SELECT * FROM user WHERE username='$user'", $link);  
$row = mysql_fetch_array($result);
if($row[id]==''){
    $returndata = array("errcode"=>1,"info"=>"用户名不存在呢","fwd"=>"/user/register.html");
    exit(json_encode($returndata));
}
if($password!=$row[password]){
    $returndata = array("errcode"=>1,"info"=>"用户名或密码错误","fwd"=>"");
    exit(json_encode($returndata));
}
if($row[qs]=='1'){
    $returndata = array("errcode"=>1,"info"=>"当前账户已被停封，请联系客服","fwd"=>"/user/login.html");
    exit(json_encode($returndata));
}
#渠道限制级
if($config['qudao']=='1'){
if($row[userid]!=$dl){
    $returndata = array("errcode"=>1,"info"=>"当前渠道您无法用此用户名登陆，请重新注册","fwd"=>"/user/register.html");
    exit(json_encode($returndata));
}
}
if($password==$row[password]){
    $returndata = array("errcode"=>1,"info"=>"success","fwd"=>$rememb);
  $_SESSION['user']=$user;
  $_SESSION['pass']=$password;
    exit(json_encode($returndata));
}

}elseif($type=='reg'){
$result= mysql_query("SELECT * FROM user WHERE username='$user'", $link);  
$row = mysql_fetch_array($result);
if($row[id]!=''){
    $returndata = array("errcode"=>1,"info"=>"您输入的用户名存在呢","fwd"=>"");
    exit(json_encode($returndata));
}
if($rowx[id]==''){
    $returndata = array("errcode"=>1,"info"=>"参数错误","fwd"=>"");
    exit(json_encode($returndata));
}
  $player=$_POST['player'];
  if($player!=''){
  $resultac= mysql_query("SELECT * FROM user WHERE qudao='$player' and ip='$ip'", $link);  
$rowac = mysql_fetch_array($resultac);
    if($rowac['id']==''){
    mysql_query("UPDATE user SET jifen=jifen+'$config[player]' WHERE id='$player'", $link); 
      $playerid=$player;
    }else{
    $playerid='';
    }
  }
  
  $date=date("Y-m-d");//时间
mysql_query("INSERT INTO user (userid, qudao, username, password, ip, date) VALUES ('$dl', '$playerid', '$user', '$password', '$ip', '$date')", $link);  
  $_SESSION['user']=$user;  //变量账号
  $_SESSION['pass']=$password; //变量密码
  $returndata = array("errcode"=>1,"info"=>"success","fwd"=>$rememb);
  exit(json_encode($returndata));
}


?>
<!--{"errcode":1,"info":"222","fwd":"/index.html"}-->